package share

import (
	"jgt-oper/src/bll"
	"jgt-oper/src/context"
)

// AuthCode 认证码管理
type AuthCode struct {
	AuthCodeBll   *bll.AuthCode   `inject:""`
	EnterpriseBll *bll.Enterprise `inject:""`
}

// Get 精确查询数据
func (a *AuthCode) Get(ctx *context.Context) error {
	item, err := a.AuthCodeBll.Get(ctx.Param("id"))
	if err != nil {
		return ctx.ResErrInternalServer(err)
	} else if item != nil {
		eitem, _ := a.EnterpriseBll.Get(item.EnterpriseID)
		if eitem != nil {
			item.EnterpriseName = eitem.Name
		}
	}
	return ctx.ResSuccess(item)
}
